﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Peking_Duck
{
    class QueryHandler
    {
         XMLParser Parser = new XMLParser();
         #region NPC Queries
         public void GenerateCreature(uint entry, uint diff1, uint diff2, uint diff3, uint kill1, uint kill2, uint model1, uint model2, uint model3, uint model4, string name, string subname, uint factionA, uint factionH, uint rank, uint scale, uint flags, uint classid, uint minlevel, uint maxlevel, uint unitflags, uint dynamicflags)
        {
            Parser.ReadXML();
            string _sWorldDatabase = Parser._sWorldDatabase;
            DateTimeOffset datetime = DateTimeOffset.Now;
            string _sDateTimeNow = datetime.UtcDateTime.ToString();
            DisplaySQL ShowSQL = new DisplaySQL();
            #region MySQL Queries
            string creatureSQL = @"
-- SQL Query generated with Peking Duck™ for table creature_template. 
-- Timestamp: " + _sDateTimeNow + @"
SET @NPCGUID := " + entry + @"; -- Creature: " + name + @" entry.
-- Warning, this will delete an existing creature in creature_template if the entry id is the same.
DELETE FROM `creature_template` WHERE `entry` = @NPCGUID;
-- Inserting generated creature " + name + @" into creature_template
INSERT INTO `creature_template` (`entry`,`difficulty_entry_1`,`difficulty_entry_2`,`difficulty_entry_3`,`KillCredit1`,`KillCredit2`,`modelid1`,`modelid2`,`modelid3`,`modelid4`,`name`,`subname`,`IconName`,`gossip_menu_id`,`minlevel`,`maxlevel`,`exp`,`faction_A`,`faction_H`,`npcflag`,`speed_walk`,`speed_run`,`scale`,`rank`,`mindmg`,`maxdmg`,`dmgschool`,`attackpower`,`dmg_multiplier`,`baseattacktime`,`rangeattacktime`,`unit_class`,`unit_flags`,`dynamicflags`,`family`,`trainer_type`,`trainer_spell`,`trainer_class`,`trainer_race`,`minrangedmg`,`maxrangedmg`,`rangedattackpower`,`type`,`type_flags`,`lootid`,`pickpocketloot`,`skinloot`,`resistance1`,`resistance2`,`resistance3`,`resistance4`,`resistance5`,`resistance6`,`spell1`,`spell2`,`spell3`,`spell4`,`spell5`,`spell6`,`spell7`,`spell8`,`PetSpellDataId`,`VehicleId`,`mingold`,`maxgold`,`AIName`,`MovementType`,`InhabitType`,`Health_mod`,`Mana_mod`,`Armor_mod`,`RacialLeader`,`questItem1`,`questItem2`,`questItem3`,`questItem4`,`questItem5`,`questItem6`,`movementId`,`RegenHealth`,`equipment_id`,`mechanic_immune_mask`,`flags_extra`,`ScriptName`,`WDBVerified`) VALUES
(@NPCGUID,                     -- entry
" + diff1 + @",                -- difficulty_entry_1
" + diff2 + @",                -- difficulty_entry_2
" + diff3 + @",                -- difficulty_entry_3
" + kill2 + @",                -- KillCredit1
" + kill2 + @",                -- KillCredit2
" + model1 + @",               -- modelid1
" + model2 + @",               -- modelid2
" + model3 + @",               -- modelid3
" + model4 + @",               -- modelid4
""" + name + @""",             -- name
""" + subname + @""",          -- subname
'',                            -- IconeName
0,                             -- gossip_menu_id
" + minlevel + @",             -- minlevel
" + maxlevel + @",             -- maxlevel
0,                             -- exp
" + factionA + @",              -- faction_A
" + factionH + @",             -- faction_h
" + flags + @",                -- npcflag
1,                             -- speed_walk
1,                             -- speed_run
" + scale + @",                -- scale
" + rank + @",                 -- rank
1,             -- mindmg
5,             -- maxdmg
0,                -- dmgschool
1504,             -- attackpower
1,                -- dmg_multiplier
1500,             -- baseattacktime
0,                -- rangeattacktime
" + classid + @",              -- unit_class
" + unitflags + @",            -- unit_flags
" + unitflags + @",            -- dynamicflags
0,                             -- family
0,                             -- trainer_type
0,                             -- trainer_spell
0,                             -- trainer_class
0,                             -- trainer_race
0,                             -- minrangedmg
0,                             -- maxrangedmg
0,                             -- rangedattackpower
0,                             -- type
0,                             -- type_flags
0,                             -- lootid
0,                             -- pickpocketloot
0,                             -- skinloot
0,                             -- resistance1
0,                             -- resistance2
0,                             -- resistance3
0,                             -- resistance4
0,                             -- resistance5
0,                             -- resistance6
0,                             -- spell1
0,                             -- spell2
0,                             -- spell3
0,                             -- spell4
0,                             -- spell5
0,                             -- spell6
0,                             -- spell7
0,                             -- spell8
0,                             -- PetSpellDataId
0,                             -- VehicleId
0,                             -- mingold
0,                             -- maxgold
'',                            -- AIName
0,                             -- MovementType
3,                             -- InhabitType
1,                             -- Health_mod
1,                             -- Mana_mod
1,                             -- Armor_mod
0,                             -- RacialLeader
0,                             -- questItem1
0,                             -- questItem2
0,                             -- questItem3
0,                             -- questItem4
0,                             -- questItem5
0,                             -- questItem6
0,                             -- movementId
1,                             -- RegenHealth
0,                             -- equipment_id
0,                             -- mechanic_immune_mask
0,                             -- flags_extra
'',                            -- ScriptName
1);                            -- WDBVerified
";
            #endregion
            ShowSQL.richtextboxSQL.Text = ""; //let's clean our little textbox.
            ShowSQL.richtextboxSQL.Text = creatureSQL;
            ShowSQL.ShowDialog();
        }
         #endregion
         #region Item Queries
        #endregion

    }
}
